package com.dmpp.mes.controller;

import com.dmpp.mes.bean.ResponseData;
import com.dmpp.mes.parameterInfo.ProductAndProcess;
import com.dmpp.mes.parameterInfo.Station;
import com.dmpp.mes.service.ProductAndProcessService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("ProductAndProcess")
public class ProductAndProcessController {
    @Autowired
    private ProductAndProcessService service;

    @RequestMapping(value = "/FindAll", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData findAll(Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        return service.findAll();
    }

    @RequestMapping(value = "/FindByProductNo", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData findByProductNo(String productNo) {
        return service.findByProductNo(productNo);
    }

    @RequestMapping(value = "/Insert", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData insert(ProductAndProcess productAndProcess) {
        return service.insert(productAndProcess);
    }

    @RequestMapping(value = "/UpdateByProductNo", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData updateByCode(ProductAndProcess productAndProcess) {
        return service.updateByProductNo(productAndProcess);
    }

    @RequestMapping(value = "/DeleteByProductNo", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData deleteByCode(String productNo) {
        return service.deleteByProductNo(productNo);
    }


}
